package com.ljsw.util;

import android.app.Activity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;

import java.util.List;

public class QunabeiSpinner extends MySpinner {
    private static final int fontSize = 30;
    private String chooseText;
    private SpinnerAdapterVersion SpinnerAdapterVersion;
//    private List<ListEditionByMoneyId> list;
    private List<String> list;
    private SpinnerAdapter SpinnerAdapter;

    public QunabeiSpinner(final Activity context, View parent, final TextView tv, List<String> list) {
        super(context, parent, tv);
        this.list = list;
        spinner_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

                chooseText = QunabeiSpinner.this.list.get(arg2);
                tv.setText(chooseText);

                QunabeiSpinner.this.dismiss();
            }

        });



        // 设置选项
        SpinnerAdapter = new SpinnerAdapter(context, list, fontSize);
        spinner_list.setAdapter(SpinnerAdapter);
    }
//
//    public QunabeiSpinner(final Activity context, View parent, final TextView tv, List<ListEditionByMoneyId> list) {
//        super(context, parent, tv);
//        this.list = list;
//        spinner_list.setOnItemClickListener(new OnItemClickListener() {
//
//            @Override
//            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
//
//                chooseText = QunabeiSpinner.this.list.get(arg2).getEditIon();
//                tv.setText(chooseText);
//
//                QunabeiSpinner.this.dismiss();
//            }
//
//        });
//        // 设置选项
//        SpinnerAdapterVersion = new SpinnerAdapterVersion(context, list, fontSize);
//        spinner_list.setAdapter(SpinnerAdapterVersion);
//
//    }

    public String getChooseText() {
        return chooseText;
    }

    public void clear() {
        chooseText = null;
        list.clear();
        SpinnerAdapterVersion.notifyDataSetChanged();
    }

}
